//
//  TeacherViewModel.m
//  HTP
//
//  Created by admin on 15/11/5.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "TeacherViewModel.h"
#import "GradeModel.h"
@implementation TeacherViewModel
-(void)getTeacherBySubject:(NSString *)subject andStart:(NSString *)start withLength:(NSString *)length{
    tns1_getTeachersBySubject *getTeacher = [[tns1_getTeachersBySubject alloc] init];
    getTeacher.subject = subject;
    getTeacher.startId = start;
    getTeacher.length = length;
    [WSDLNetWork shareInstance:^interfaceSoapBindingResponse *(interfaceSoapBinding *binding) {
        return [binding getTeachersBySubjectUsingParameters:getTeacher headerElements:nil];
    } withResult:^(NSDictionary *message) {
        [self fetchResult:message];
    } throwError:^(NSError *error) {
        [self fetchError];
    }];
}
-(void)getTeacherInfoByTeacherId:(NSString *)teacherId{
    tns1_getTeacherInfoByTeacherId *getTeacherInfo = [[tns1_getTeacherInfoByTeacherId alloc] init];
    getTeacherInfo.teacherId = teacherId;
    getTeacherInfo.parentId = [USERCONTENT getUserParentId];
    [WSDLNetWork shareInstance:^interfaceSoapBindingResponse *(interfaceSoapBinding *binding) {
        return [binding getTeacherInfoByTeacherIdUsingParameters:getTeacherInfo headerElements:nil];
    } withResult:^(NSDictionary *message) {
        [self fetchResult:message];
    } throwError:^(NSError *error) {
        [self fetchError];
    }];
}

- (void)getGradeInfo{
    tns1_getGradeInfo *getGradeInfo = [[tns1_getGradeInfo alloc] init];
    
    [WSDLNetWork shareInstance:^interfaceSoapBindingResponse *(interfaceSoapBinding *binding) {
        return [binding getGradeInfoUsingParameters:getGradeInfo headerElements:nil];
    } withResult:^(NSDictionary *message) {
        if ([message[INTERFACE_RESULT] isEqualToString:INTERFACE_SUCCESS]) {
            NSArray *dataArray = [GradeModel mj_objectArrayWithKeyValuesArray:message[INTERFACE_INFO]];
            [USERCONTENT saveGradeInfo:dataArray];
        }
        [self fetchResult:message];
    } throwError:^(NSError *error) {
        [self fetchError];
    }];
}
- (void)selectSortTeacher:(NSString *)courseName gradeName:(NSString *)gradeName teacherCity:(NSString *)teacherCity teacherSexy:(NSString *)teacerSexy teacherMethod:(NSString *)teacherMethod teacherType:(NSString *)teacherType sortType:(NSString *)sortType preLongitude:(NSString *)preLongitude preLatitude:(NSString *)preLatitude{
    tns1_getTeacherSetFilter *getTeacherSet = [[tns1_getTeacherSetFilter alloc] init];
    getTeacherSet.courseName = courseName;
    getTeacherSet.gradeName  = gradeName;
    getTeacherSet.teacherCity = teacherCity;
    getTeacherSet.teacherSex = teacerSexy;
    getTeacherSet.teacherMethod = teacherMethod;
    getTeacherSet.teacherType = teacherType;
    getTeacherSet.sortType = sortType;
    getTeacherSet.preLatitude = preLatitude;
    getTeacherSet.preLongitude = preLongitude;
    [WSDLNetWork shareInstance:^interfaceSoapBindingResponse *(interfaceSoapBinding *binding) {
        return [binding getTeacherSetFilterUsingParameters:getTeacherSet headerElements:nil];
    } withResult:^(NSDictionary *message) {
        [self fetchResult:message];
    } throwError:^(NSError *error) {
        [self fetchError];
    }];
}
- (void)addUserStore:(NSNumber *)teacherUserId userStoreType:(NSNumber *)userType{
    tns1_addUserStore *addUserStore = [[tns1_addUserStore alloc] init];
    addUserStore.teacherUserId = [teacherUserId stringValue];
    addUserStore.parentUserId = [USERCONTENT getUserId];
    addUserStore.storeType = [userType stringValue];
    [WSDLNetWork shareInstance:^interfaceSoapBindingResponse *(interfaceSoapBinding *binding) {
        return [binding addUserStoreUsingParameters:addUserStore headerElements:nil];
    } withResult:^(NSDictionary *message) {
        [self fetchResult:message];
    } throwError:^(NSError *error) {
        [self fetchError];
    }];
}
@end
